/*
 * @Description:
 * @Author: Dxcr
 * @Date: 2022-11-25 14:47:24
 * @LastEditTime: 2024-09-06 10:01:08
 * @LastEditors: Dxcr
 */
import mitt from "@/utils/mitt.js";
export default class HomeControl {
    constructor(func){
        this._func = func
    }
  onAdd(map) {
    this._map = map;
    let dom = document.createElement("div");
    this._container = dom

    dom.className = "mapboxgl-ctrl mapboxgl-ctrl-group";
    dom.innerHTML = `<button class="mapboxgl-ctrl-home" style="display:flex;align-items:center;justify-content:center;" type="button" >
		<svg t="1725588043818" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="3748" width="20" height="20"><path d="M555.885714 146.285714c168.228571 21.942857 299.885714 153.6 321.828572 321.828572h138.971428c7.314286 0 7.314286 7.314286 7.314286 7.314285v65.828572c0 7.314286-7.314286 7.314286-7.314286 7.314286H877.714286c-21.942857 168.228571-153.6 299.885714-321.828572 321.828571v138.971429c0 7.314286-7.314286 7.314286-7.314285 7.314285h-73.142858c-7.314286 0-7.314286-7.314286-7.314285-7.314285V877.714286C299.885714 855.771429 168.228571 724.114286 146.285714 555.885714H7.314286L0 548.571429v-73.142858c0-7.314286 7.314286-7.314286 7.314286-7.314285H146.285714C168.228571 299.885714 299.885714 168.228571 468.114286 146.285714V7.314286l7.314285-7.314286h65.828572c7.314286 0 7.314286 7.314286 7.314286 7.314286V146.285714zM512 789.942857c153.6 0 277.942857-124.342857 277.942857-277.942857S665.6 234.057143 512 234.057143 234.057143 358.4 234.057143 512s124.342857 277.942857 277.942857 277.942857z m0-416.914286c36.571429 0 73.142857 14.628571 95.085714 36.571429 29.257143 29.257143 43.885714 65.828571 43.885715 102.4s-14.628571 73.142857-43.885715 95.085714c-21.942857 29.257143-58.514286 43.885714-95.085714 43.885715s-73.142857-14.628571-95.085714-43.885715c-29.257143-21.942857-43.885714-58.514286-43.885715-95.085714s14.628571-73.142857 36.571429-95.085714c29.257143-29.257143 65.828571-43.885714 102.4-43.885715z" opacity=".65" p-id="3749" fill="#000000"></path></svg>
	</button>`
    dom.addEventListener('click',()=>{
        this._func()
    })
    
    return dom;
  }

  onRemove() {
    this._container.parentNode.removeChild(this._container);
    this._map = undefined;
  }
}